<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>课程订单管理</h2>
    </div>

    <div class="cf">
        <div class="search-form fr cf">
            <div class="sleft">
                <input type="text" name="title" class="search-input" value="{$Think.get.mobile}" placeholder="请输入用户手机号">
                <a class="sch-btn" href="javascript:;" id="search" url="__SELF__"><i class="btn-search"></i></a>
            </div>
        </div>
            <span>今日订单数量：{$total.todayorders}，</span><span>今日订单总额：{$total.todaytotal}元</span><br/>
            <span>本月订单数量：{$total.monthorders}，</span><span>本月订单总额：{$total.monthtotal}元</span>
        <!-- 高级搜索 -->
    </div>
<!--     <button class="btn" id="del">删  除</button>
 -->    <div class="data-table table-striped">
        <form class="ids">
            <table>
                <thead>
                    <tr>
                        <!-- <th class="row-selected">
                            <input class="checkbox check-all" type="checkbox">
                        </th>
 -->                        <th>订单号</th>
                        <th>购买用户昵称</th>
                        <th>手机号</th>
                        <th>授课老师昵称</th>
                        <th>课程名称</th>
                        <th>购买课时</th>
                        <th>订单总额</th>
                        <th>购买时间&nbsp;
                            <select name="range" class="range">
                                <option value="">全部</option>
                                <option value="1" <eq name="Think.get.range" value="1">selected="selected"</eq> >今天</option>
                                <option value="2" <eq name="Think.get.range" value="2">selected="selected"</eq> >本月</option>
                            </select></th>
                        <th>支付状态</th>
                    </tr>
                </thead>
                <tbody>
				<notempty name="data.0">
                <volist name="data.0" id="v">
                    <tr>
                       <!--  <td><input class="check" type="checkbox" name="ids[]" value="{$v.id}"></td> -->
                        <td>{$v.order}</td>
                        <td><a href="__MODULE__/UserMember/userdetails/id/{$v.uid}">{$v.uid|getUsername=###}</a></td>
                        <td>{$v.mobile}</td>
                        <td><a href="__MODULE__/UserMember/userdetails/id/{$v.tid}">{$v.tid|getUsername=###}</a></td>
                        <td>{$v.cid|getCoursename=###}</td>
                        <td>{$v.num}节</td>
                        <td>{$v.price}元</td>
                        <td>{$v.order|date='Y-m-d H:m:s',###}</td>
                        <td><eq name="v.status" value="0">未支付<else/>已支付</eq></td>
                    </tr>
                </volist>
				<else/>
				<td colspan="10" class="text-center"> aOh! 暂时还没有内容! </td>
				</notempty>
                </tbody>
            </table>
        </form>
        <!-- 分页 -->
        <div class="page">
            {$data.1}
        </div>
    </div>
</block>

<block name="script">
    <script type="text/javascript">
        $(function() {
            $('.oper').click(function(){
                var mes = $(this).html();
                if (confirm('确定要' + mes + '吗？')) {
                    var id = $(this).attr('data');
                    var val = $(this).attr('val');
                    var flag = $(this).attr('flag');
                    $.post('__CONTROLLER__/edit', {'id': id,'val':val, 'flag':flag}, function(msg) {
                        alert(msg);
                        location.reload();
                    });   
                }                             
            });

            //订单筛选
            $('.range').change(function(){
                var href = '__ACTION__'
                var mobile = '{$Think.get.mobile}';
                if (mobile != '') {
                    href += '/mobile/' + mobile;
                }
                location.href = href + '/range/' + $('.range').val();
            });

            //选择用户行为筛选
            // $('select').change(function(){
            //     filt('-1',$(this).val(),'-1');
            // });

            //只看此用户
            // $('.showone').click(function(){
            //     filt($(this).attr('data'),'-1','-1');
            // })

            // function filt(uid,action,record){
            //     if (uid == '-1') {
            //         uid = "{$Think.get.uid}";
            //     }
            //     if (action == '-1') {
            //         action = "{$Think.get.action}";
            //     }
            //     if (record == '-1') {
            //         record = "{$Think.get.record}";
            //     }
            //     location.href = "__ACTION__" + "/uid/" + uid + "/action/" + action + "/record/" + record;
            // }

            //记录按钮默认颜色
            // $('.r' + "{$Think.get.record}").css('background','#0c7dac');

            
            //搜索功能
            $("#search").click(function() {
                var sear = '__ACTION__';
                var range = '{$Think.get.range}';
                if (range != '') {
                    sear += '/range/'+range;
                }
                window.location.href = sear+'/mobile/' + $('.search-input').val();
            });
            
            //导航高亮
            highlight_subnav('{:U('index')}');

            //回车搜索
            $(".search-input").keyup(function(e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });
            //全选
            $('.check-all').change(function(){
                if ($(this).is(':checked')) {
                    $('.check').prop('checked',true);
                } else {
                    $('.check').prop('checked',false);
                }
            });
            //删除
            $('#del').on('click',function(){
                var msg = confirm('你确定要删除吗？ ');
                if(msg){
                 var obj = $('.check');
                 check_val = [];
                    for(k in obj){
                        if(obj[k].checked)
                            check_val.push(obj[k].value);
                    }
                   $.ajax({
                       url: "{:U('ajaxDel')}",
                       type: 'POST',
                       data: {ids: check_val},
                       success:function(data){
                        layer.msg('消息删除成功', {
                          time: 20000, //20s后自动关闭
                                });
                       }
                   });
                    location.reload();
                }
            })
        });
    </script>
</block>